﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PcCtrlUI
{
	/// <summary>
	/// Interaction logic for LightCtrl.xaml
	/// </summary>
	public partial class LightCtrl : UserControl
	{
        private int ch;

        public int Ch
        {
            get { return ch; }
            set { ch = value; }
        }

		public LightCtrl()
		{
			this.InitializeComponent();
		}
		
		public void setName(string name)
		{
			this.name.Content = name;
		}
		
		public void setValue(double value)
		{
            this.bar.Value = value;
            this.value.Content = value + "%";
		}

        private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            App app = (App)App.Current;
            int v = (int)Math.Round(e.NewValue * 10.0);
            if (ch > 2)
            {
                app.getMcCOMChannel().set230VDIM(ch, v);
            }
            else
            {
                app.getMcCOMChannel().setLEDPWM(ch, v);
            }
            
        }

	}
}